package com.andy.common.utils

import android.view.View
import android.view.ViewTreeObserver

/**
 * @author Andy
 * @date 2023/8/30
 * @description OnViewGlobalLayoutWidthListener
 */
class OnViewGlobalLayoutWidthListener(private var view: View, private var maxWidth: Int) : ViewTreeObserver.OnGlobalLayoutListener {
    override fun onGlobalLayout() {
        if (view.width > maxWidth) {
            view.layoutParams.width = maxWidth
        }
    }
}